package com.mlk.engSystem.controller;

import com.mlk.core.component.page.Pager;
import com.mlk.core.util.ServerResponse;
import com.mlk.engSystem.po.EngSysEmp;
import com.mlk.engSystem.po.EngSysEmpRemainLog;
import com.mlk.engSystem.po.EngSysRefUserArea;
import com.mlk.engSystem.po.EngUserWasteType;
import com.mlk.engSystem.service.EngSysEmpService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/eng/system/emp")
public class EngSystemEmpController {

    @Resource
    private EngSysEmpService engSysEmpService;

    /**
     * 回到员工管理首页
     * @return
     */
    @RequestMapping("index")
    public String index(){
        return "engSystem/emp";
    }


    /**
     * 分页数据
     * @return
     */
    @ResponseBody
    @RequestMapping("listPage")
    public Pager listPage(){
        return this.engSysEmpService.listPage();
    }

    /**
     * 员工添加
     * @param emp
     * @return
     */
    @RequestMapping("add")
    @ResponseBody
    public ServerResponse add(EngSysEmp emp){
        return this.engSysEmpService.add(emp);
    }


    /**
     * 修改员工的基本信息
     */
    @RequestMapping("editEmp")
    @ResponseBody
    public ServerResponse editEmp(EngSysEmp emp){
        return this.engSysEmpService.editEmp(emp);
    }

    /**
     * 雇员修改
     * @param emp
     * @return
     */
    @ResponseBody
    @RequestMapping("modify")
    public ServerResponse modify(EngSysEmp emp){
        return this.engSysEmpService.modify(emp);
    }

    /**
     * 员工划分片区
     * @param lists
     * @return
     */
    @RequestMapping("allocateArea")
    @ResponseBody
    public ServerResponse allocateArea(@RequestBody List<EngSysRefUserArea> lists,Integer id){
        return this.engSysEmpService.allocateArea(lists,id);
    }

    /**
     * 分配废品类型
     * @param lists
     * @param id
     * @return
     */
    @RequestMapping("allocateWasteType")
    @ResponseBody
    public ServerResponse allocateWasteType(@RequestBody List<EngUserWasteType> lists,Integer id){
        return this.engSysEmpService.allocateWasteType(lists,id);
    }

    /**
     * 员工分配暂存区
     * @return
     */
    @RequestMapping("allocateDeposit")
    @ResponseBody
    public ServerResponse allocateDeposit(Integer depositId,Integer id){
        return this.engSysEmpService.allocateDeposit(depositId,id);
    }

    /**
     * 查询用户所有选择的废品类型
     * @param id
     * @return
     */
    @RequestMapping("selectEmpAllCheckedWasteType")
    @ResponseBody
    public ServerResponse selectEmpAllCheckedWasteType(Integer id){
        return this.engSysEmpService.selectEmpAllCheckedWasteType(id);
    }

    /**
     * 查询用户所有的区域信息
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping("selectEmpAllArea")
    public ServerResponse selectEmpAllArea(Integer id){
        return this.engSysEmpService.selectEmpAllArea(id);
    }

    /**
     * 管理员给业务员分配额度
     * @param log
     * @return
     */
    @RequestMapping("allocateRemain")
    @ResponseBody
    public ServerResponse allocateRemain(EngSysEmpRemainLog log){
        return this.engSysEmpService.allocateRemain(log);
    }

    /**
     * 判断人员是否已经分配暂存区
     * @return
     */
    @RequestMapping("isAllocateCar")
    @ResponseBody
    public ServerResponse isAllocateCar(Integer id){
        return this.engSysEmpService.isAllocateCar(id);
    }

    /**
     * 获取员工可以使用的车辆的信息
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping("getAllCanUseCar")
    public Pager getAllCanUseCar(Integer id){
        return this.engSysEmpService.getAllCanUseCar(id);
    }

    /**
     * 分配车辆
     * @param emp
     * @return
     */
    @RequestMapping("allocateCar")
    @ResponseBody
    public ServerResponse allocateCar(EngSysEmp emp){
     return this.engSysEmpService.allocateCar(emp);
    }
}
